import { BaseItem } from "../../common/BaseItem";
import { ItemData } from "../../../resource/info/ItemData";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class PetMingBaseItem
    
    export  class PetMingBaseItem extends BaseItem
    {
        constructor()
        {
            super();
            this.init();
            this.setSize(54, 54);
            this.mouseChildren = false;
            this.toolTipType = ItemData.ToolTipType_PetLifeStyle;
            return;
        }

        public set isShowName(arg1: Boolean)
        {
            this._isShowName = arg1;
            this._nameTxt.visible = arg1;
            return;
        }

        public set isWordWrap(arg1: Boolean)
        {
            this._isWordWrap = arg1;
            return;
        }

        public set isShowLevel(arg1: Boolean)
        {
            this._levelTxt.visible = arg1;
            return;
        }

        public setNamePos(arg1: int=-1, arg2: int=-1): void
        {
            if (arg1 != -1) 
            {
                this._nameTxt.x = arg1;
            }
            if (arg2 != -1) 
            {
                this._nameTxt.y = arg2;
            }
            return;
        }

        public /* override */ set itemData(arg1: ItemData)
        {
            super.itemData = arg1;
            _itemData = arg1;
            if (arg1) 
            {
                this.swfName = arg1.itemInfo.item.icon + ".swf";
                this._levelTxt.text = "Lv." + arg1.lsLevel;
                if (this._isWordWrap && arg1.name.length > 4) 
                {
                    this._showName = "   " + arg1.name.substr(0, 2) + "\n" + arg1.name.substr(2);
                    this._showName = HTMLUtil.addColor(this._showName, ColorConfig.instance.getItemColor(itemData.color).color);
                }
                else 
                {
                    this._showName = ItemsUtil.getItemName(arg1);
                }
                this._nameTxt.htmlText = this._showName;
                this._effectPlayer.play();
            }
            else 
            {
                if (this._effectPlayer && this._effectSprite.contains(this._effectPlayer)) 
                {
                    this._effectSprite.removeChild(this._effectPlayer);
                    this._effectPlayer.stop();
                }
                this._nameTxt.text = "";
                this._levelTxt.text = "";
            }
            return;
        }

        public /* override */ set source(arg1: Object)
        {
            return;
        }

        public set swfName(arg1: string)
        {
            this._swfName = arg1;
            if (!this._effectPlayer) 
            {
                this._effectPlayer = new SWFPlayer();
            }
            if (!this._effectSprite.contains(this._effectPlayer)) 
            {
                this._effectSprite.addChild(this._effectPlayer);
            }
            this._effectPlayer.timeRate = 2;
            this._effectPlayer.load(this._swfName, ModelType.NormalSwf, null);
            return;
        }

        public get uid(): string
        {
            return this._uid;
        }

        public set uid(arg1: string)
        {
            this._uid = arg1;
            return;
        }

        /* internal  */init(): void
        {
            this._effectSprite = new Object /* flash.display.Sprite */();
            this._effectSprite.x = 27;
            this._effectSprite.y = 27;
            effectLayer.addChild(this._effectSprite);
            this._nameTxt = ObjCreate.createGTextField("", -6, 25, 70, 20, this);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._nameTxt.mouseEnabled = false;
            this._nameTxt.multiline = true;
            this._levelTxt = ObjCreate.createGTextField("", -7, 40, 70, 20, this);
            this._levelTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._levelTxt.mouseEnabled = false;
            return;
        }

        public get effectPlayer(): SWFPlayer
        {
            return this._effectPlayer;
        }

        public /* var */_effectSprite: Object /* flash.display.Sprite */;

        public /* var */_nameTxt: GTextFiled;

        public /* var */_levelTxt: GTextFiled;

        /* internal */ /* var */_effectPlayer: SWFPlayer;

        /* internal */ /* var */_swfName: string;

        /* internal */ /* var */_uid: string;

        /* internal */ /* var */_ls_level: int;

        /* internal */ /* var */_isShowName: Boolean;

        /* internal */ /* var */_isWordWrap: Boolean;

        /* internal */ /* var */_showName: string;
    }
